package com.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URISyntaxException;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.web.servlet.db.GameDaoImpl;
import com.web.servlet.db.IGameDao;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.web.servlet.config.Config;
import com.web.servlet.dao.DBConnect;
import com.web.servlet.db.pool.DBPoolMgr;
import com.web.servlet.manager.GameServerMananger;
import com.web.servlet.manager.RedisManager;

public class MainServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final Logger log = LoggerFactory.getLogger(MainServlet.class);
	public MainServlet() {
		super();
	}

	public void destroy() {
		super.destroy(); 
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		super.service(req, resp);
		
	}
	
	@Override
	public void service(ServletRequest req, ServletResponse res)
			throws ServletException, IOException {
		super.service(req, res);
		
	}


	public void init() throws ServletException {
		System.out.println("MainServlet.init()11111111111111111111111111111111111");
		
		try {
			System.out.println("ggggggggggggggggggg:-----"+ClassLoader.getSystemResource("redis.properties"));
			//加载配置文件
			Config.init(this.getClass().getResource("//").toURI().getPath());
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//加载redis
		RedisManager.getInstance().init();
		log.error("加载数据库--start");
		DBPoolMgr.init( 10,1, 10, 1);
		log.error("加载数据库--end");
		/*IGameDao gameDao = new GameDaoImpl();
		gameDao.getBackPlayerByAccount("test");*/
		//加载游戏列表
		//GameServerMananger.getInstance().init();
		//注册
		//登录
		//获得游戏信息
		//获得选中游戏信息 和token
		
	}

}
